﻿Public Class PortNumbersDialog
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SingleGameOnly = SingleGameCheckBox.Checked
        DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Sub New()
        InitializeComponent()

        With My.Application.CommandLineArgs
            If .Contains("/m") Then
                MainPortTB.Text = .Item(.IndexOf("/m") + 1)
                MainPortTB.Enabled = False
            End If
            If .Contains("/w") Then
                WebPortTB.Text = .Item(.IndexOf("/w") + 1)
                WebPortTB.Enabled = False
            End If
            If .Contains("/u") Then
                URITB.Text = .Item(.IndexOf("/u") + 1)
                URITB.Enabled = False
            Else
                URITB.Text = My.Computer.Name
            End If
            If .Contains("/n") Then
                ServerNameTB.Text = .Item(.IndexOf("/n") + 1)
                ServerNameTB.Enabled = False
            End If
            If .Contains("/SINGLE") Then
                SingleGameCheckBox.Checked = True
                SingleGameCheckBox.Enabled = False
                SingleGameOnly = True
            ElseIf .Contains("/-SINGLE") Then
                SingleGameCheckBox.Checked = False
                SingleGameCheckBox.Enabled = False
                SingleGameOnly = False
            End If
        End With
    End Sub

    Private Sub PortNumbersDialog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If My.Application.CommandLineArgs.Contains("/a") And Not My.Application.CommandLineArgs.Contains("/-s") _
                Or My.Application.CommandLineArgs.Contains("/s") Then
            Button1.PerformClick()
        End If
    End Sub
End Class